<template>
  <div class="playlist">
    <!-- 头部 -->
    <div class="playlist-header">
      <!-- 左侧播放按钮 -->
      <div class="bofang">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-bofang1" />
        </svg>
        <div>
          播放全部
          <span>(共{{playlist.tracks.length}}首)</span>
        </div>
      </div>
      <!-- 右侧收藏按钮 -->
      <div class="shoucang">+ 收藏({{playlist.subscribedCount}})</div>
    </div>

    <!-- 列表部分 -->
    <div class="list">
      <div class="list-item" v-for="(item, index) in playlist.tracks" :key="item.id" @click="play(item,index)">
        <div class="item-left">
          <div class="music-index">{{index+1}}</div>

          <div class="music-detail">
            <div class="music-name">{{item.name}}</div>
            <div class="music-author">
              <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-vip" />
              </svg>
              {{item.ar[0].name}}
            </div>
          </div>
        </div>
        <div class="item-right">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-boshiweb_bofangliang" />
          </svg>
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-gengduo" />
          </svg>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['playlist'],
  methods: {
    play(item, index) {
      // this.$store.commit('setPlayList', item)
      this.$store.commit('setPlayCurrentIndex', index)
    }
  }
}
</script>

<style lang="less" scoped>
.playlist {
  background-color: white;
  border-top-left-radius: 0.2rem;
  border-top-right-radius: 0.2rem;
  // 为歌曲控制组件腾出空间 padding-bottom 1rem
  padding: 0.1rem 0.3rem 1rem;
  position: absolute;
  left: 0;
  width: 7.5rem;
  .playlist-header {
    display: flex;
    justify-content: space-between;
    height: 1rem;
    align-items: center;
    .bofang {
      display: flex;
      align-items: center;
      .icon {
        width: 0.55rem;
        height: 0.55rem;
        margin-right: 0.2rem;
      }
      div {
        font-size: 0.3rem;
        span {
          font-size: 0.23rem;
          color: #ccc;
        }
      }
    }
    .shoucang {
      background-color: rgb(245, 60, 60);
      height: 1rem;
      width: 2rem;
      border-radius: 1rem;
      line-height: 1rem;
      text-align: center;
      margin-right: -0.1rem;
      font-size: 0.25rem;
      color: white;
    }
  }
  .list {
    width: 100%;
    .list-item {
      padding: 0.25rem 0;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .item-left {
        display: flex;
        align-items: center;
        .music-index {
          width: 0.8rem;
          height: 0.8rem;
          padding-left: 0.2rem;
          line-height: 0.8rem;
          color: #999;
          font-size: 0.3rem;
        }
        .music-detail {
          width: 5rem;
          .music-name {
            font-size: 0.28rem;
          }
          .music-author {
            padding-top: 0.05rem;
            font-size: 0.25rem;
            color: #999;
            display: flex;
            align-items: center;
            .icon {
              width: 0.7rem;
              height: 0.4rem;
              padding-top: 0.05rem;
            }
          }
        }
      }
      .item-right {
        .icon {
          width: 0.4rem;
          height: 0.4rem;
          margin-left: 0.15rem;
        }
      }
    }
  }
}
</style>